﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dreamz
{
    public class Rum9
    {
       static public void Apply()
       {
          //initializes the value Door.S.NoOfShapes to 0
          Door.S.NoOfShapes = 0;
       }
        static public void InsertShape(string shape)
        {
            if (GameEngine.S.Player.X == 2 && GameEngine.S.Player.Y == 3)
            {
                string UseTarget;
                UI.Console.WriteLine("What do you want to use the {0} on?\n", shape);
                UI.Draw();
                UseTarget = Console.ReadLine().ToLower();
                //Asks what you want to do with your shape (shape wood etc)
                if (UseTarget == "hole" || UseTarget == "holes" || UseTarget == "door")
                {
                   //if you want to use it on the opening-mechanism
                   Door.S.NoOfShapes++;
                   //Increases NoOfShapes with 1. Helpful to determine number of shapes inserted into the door.
                    UI.Console.WriteLine("You insert the {0} into the {1}-shaped hole.\n", shape, shape);
                    UI.Draw();
                    //Confirmation that you succeeded
                    switch (shape)
                    {
                        case "ball":
                            Door.S.ball = true;
                            Door.S.ballDescription="ball";
                            break;
                        case "triangle":
                            Door.S.triangle = true;
                            Door.S.triangleDescription = "triangle";
                            break;
                        case "cube":
                            Door.S.cubeDescription = "cube";
                            Door.S.cube = true;
                            break;
                    }
                    //Sets different bools of the public class door to true depending on what shapes you've inserted.
                    if (Door.S.NoOfShapes == 1)
                       GameEngine.S.World[2, 3].Items["hole"].Description = String.Format("These holes are shaped in different geometrical figures, \nthere are holes for a triangle, a square and a ball. \nThe {0}{1}{2}-shaped hole is filled.", Door.S.triangleDescription, Door.S.ballDescription, Door.S.cubeDescription);
                    //As only one of these values have any information, this string will give the correct information to the description of the holes.
                    else if (Door.S.NoOfShapes == 2 && Door.S.ball)
                        GameEngine.S.World[2, 3].Items["hole"].Description = String.Format("These holes are shaped in different geometrical figures, \nthere are holes for a triangle, a square and a ball.  \nTwo of the shaped are filled, the ball-shaped one, as well as the {0}{1}-shaped one.\n", Door.S.triangleDescription, Door.S.cubeDescription);
                    else if (Door.S.NoOfShapes == 2 && Door.S.cube)
                        GameEngine.S.World[2, 3].Items["hole"].Description = String.Format("These holes are shaped in different geometrical figures, \nthere are holes for a triangle, a square and a ball. \nTwo of the shaped are filled, the cube-shaped one, as well as the {0}{1}-shaped one.\n", Door.S.triangleDescription, Door.S.ballDescription);
                    else if (Door.S.NoOfShapes == 2 && Door.S.triangle)
                        GameEngine.S.World[2, 3].Items["hole"].Description = String.Format("These holes are shaped in different geometrical figures, \nthere are holes for a triangle, a square and a ball. \nTwo of the shaped are filled, the triangle-shaped one, as well as the {0}{1}-shaped one.\n", Door.S.ballDescription, Door.S.cubeDescription);
                    else if (Door.S.NoOfShapes == 3)
                    {
                        GameEngine.S.World[2, 3].Items["hole"].Description = String.Format("All the holes are filled, the one shaped as a triangle, \nthe one shaped as a ball, as well as the one shaped as a cube.\n");
                       GameEngine.S.World[2, 3].North = true;
                       UI.Console.Write("The Door is slowly opening, good job!\n");
                       UI.Draw();
                    }
                }
                else
                {
                   UI.Console.Write("Stop this gibberish!\n");
                   UI.Draw();
                }
            }
            else
            {
               UI.Console.Write("Stop this gibberish!\n");
               UI.Draw();
            }
        }
    }
}
